<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page import="com.tust.app.domain.User" %> <!-- 替换为您的实际包路径 -->
<%
    pageContext.setAttribute("APP_PATH", request.getContextPath());
%>
<%
    User currentUser = (User) session.getAttribute("currentUser"); // 从Session中获取用户对象
    String userId = currentUser != null ? String.valueOf(currentUser.getId()) : ""; // 获取用户ID
%>
<!DOCTYPE HTML>
<html>
<head>
    <title>修改用户信息</title>
    <link href="${APP_PATH}/static/img/secured.jpg" rel="shortcut icon">
    <link rel="stylesheet" href="${APP_PATH}/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${APP_PATH}/static/css/style.css">
    <script src="${APP_PATH}/static/js/jquery-3.3.1.min.js"></script>
    <script src="${APP_PATH}/static/bootstrap/js/bootstrap.min.js"></script>
    <script src="${APP_PATH}/static/js/jquery.validate.min.js"></script>
    <script src="${APP_PATH}/static/js/messages_zh.js"></script>
    <script src="${APP_PATH}/static/js/check.js"></script>
</head>
<body>
<div class="container" style="margin-top: 200px;">
    <form class="col-sm-offset-4 col-sm-4 col-sm-offset-4 form form-horizontal" action="${APP_PATH}/updateUser" method="post" id="update_form">
        <h3 class="text-center">修改用户信息</h3>
        <div class="errorMsg"><span>${errorMsg}</span></div>
        <input type="hidden" name="id" value="<%= userId %>"> <!-- 将ID作为隐藏字段传递 -->
        <div class="form-group">
            <label for="username" class="col-sm-2 control-label">账&nbsp;号</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名" value="${currentUser != null ? currentUser.getUsername() : ''}">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">密&nbsp;码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
            </div>
        </div>
        <div class="form-group">
            <label for="email" class="col-sm-2 control-label">邮&nbsp;箱</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="email" name="email" placeholder="请输入邮箱" value="${currentUser != null ? currentUser.getEmail() : ''}">
            </div>
        </div>
        <button type="submit" class="btn btn-success center-block">确定修改</button>
        <div class="text-right">
            <a href="home.jsp">返回上一页</a>
        </div>
    </form>
</div>
</body>
</html>